Skip to content

Avoid masking user exception with ??? for Nothing typed expressions #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2015

Conversation

retronym
Copy link
Member

Code like:

val x = if (cond) throw new A else throw new B

Was being transformed to:

val ifRes = ???
if (cond) ifRes = throw new A else ifRes = throw new B
val x = ifRes

by way of the use of gen.mkZero which throws ??? if the requested type is Nothing

This commit special cases Nothing typed expressions in a similar manner to Unit type expressions.
The example above is now translated to:

if (cond) throw new A else throw new B
val x = throw new IllegalStateException()

Fixed #120

@retronym retronym force-pushed the ticket/120 branch 2 times, most recently from 46a6c1b to 966a84d Compare July 27, 2015 03:13
Code like:

    val x = if (cond) throw new A else throw new B

Was being transformed to:

    val ifRes = ???
    if (cond) ifRes = throw new A else ifRes = throw new B
    val x = ifRes

by way of the use of `gen.mkZero` which throws `???` if the requested type is `Nothing`

This commit special cases `Nothing` typed expressions in a similar manner to `Unit` type expressions.
The example above is now translated to:

    if (cond) throw new A else throw new B
    val x = throw new IllegalStateException()

Fixes scala#120
retronym added a commit that referenced this pull request Jul 27, 2015
Avoid masking user exception with ??? for Nothing typed expressions
@retronym retronym merged commit 43c0287 into scala:master Jul 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant